package com.gitee.wsl.func.filter.bloomfilter

import com.gitee.wsl.func.filter.bloomfilter.api.BitMapExtractor
import com.gitee.wsl.func.filter.bloomfilter.api.BloomFilter
import com.gitee.wsl.func.filter.bloomfilter.api.Hasher
import com.gitee.wsl.func.filter.bloomfilter.api.IndexExtractor
import com.gitee.wsl.func.filter.bloomfilter.bean.Shape
import com.gitee.wsl.func.predicate.IntPredicate
import com.gitee.wsl.func.predicate.LongBiPredicate
import com.gitee.wsl.func.predicate.LongPredicate


/**
 * An abstract class to assist in implementing Bloom filter decorators.
 *
 * @param <T> The WrappedBloomFilter type.
 * @param <W> The *wrapped* BloomFilter type.
 * @since 4.5.0-M1
</W></T> */
abstract class WrappedBloomFilter<T : WrappedBloomFilter<T, W>, W : BloomFilter<W>>(
    /**
     * Gets the wrapped BloomFilter.
     *
     * @return the wrapped BloomFilter.
     */
    protected val wrapped: W,
) : BloomFilter<T> {
     override fun asBitMapArray(): LongArray {
        return wrapped.asBitMapArray()
    }

     override fun asIndexArray(): IntArray {
        return wrapped.asIndexArray()
    }

     override fun cardinality(): Int {
        return wrapped.cardinality()
    }

     override fun characteristics(): Int {
        return wrapped.characteristics()
    }

     override fun clear() {
        wrapped.clear()
    }

     override fun contains(bitMapExtractor: BitMapExtractor): Boolean {
        return wrapped.contains(bitMapExtractor)
    }

     override fun contains(other: BloomFilter<*>): Boolean {
        return wrapped.contains(other)
    }

     override fun contains(hasher: Hasher): Boolean {
        return wrapped.contains(hasher)
    }

     override fun contains(indexExtractor: IndexExtractor): Boolean {
        return wrapped.contains(indexExtractor)
    }

     override fun estimateIntersection(other: BloomFilter<*>): Int {
        return wrapped.estimateIntersection(other)
    }

     override fun estimateN(): Int {
        return wrapped.estimateN()
    }

     override fun estimateUnion(other: BloomFilter<*>): Int {
        return wrapped.estimateUnion(other)
    }

    override val shape: Shape
        get() = wrapped.shape

    override fun isFull(): Boolean {
        return wrapped.isFull()
    }

     override fun merge(bitMapExtractor: BitMapExtractor): Boolean {
        return wrapped.merge(bitMapExtractor)
    }

     override fun merge(other: BloomFilter<*>): Boolean {
        return wrapped.merge(other)
    }

     override fun merge(hasher: Hasher): Boolean {
        return wrapped.merge(hasher)
    }

     override fun merge(indexExtractor: IndexExtractor): Boolean {
        return wrapped.merge(indexExtractor)
    }

     override fun processBitMapPairs(other: BitMapExtractor, func: LongBiPredicate): Boolean {
        return wrapped.processBitMapPairs(other, func)
    }

     override fun processBitMaps(predicate: LongPredicate): Boolean {
        return wrapped.processBitMaps(predicate)
    }

     override fun processIndices(predicate: IntPredicate): Boolean {
        return wrapped.processIndices(predicate)
    }
}
